import 'package:flutter/material.dart';
import 'package:flutter_demo/tmac/widget/AllDrawableTextWidget2.dart';
import 'package:flutter_demo/wzw/mybutton.dart';


void main() => runApp(aaa());
class aaa extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: new SwitchAndCheckBoxTestRoute(),
    );
  }

}
class SwitchAndCheckBoxTestRoute extends StatefulWidget {
  @override
  _SwitchAndCheckBoxTestRouteState createState() => new _SwitchAndCheckBoxTestRouteState();
}

class _SwitchAndCheckBoxTestRouteState extends State<SwitchAndCheckBoxTestRoute> {
  bool _switchSelected=true; //维护单选开关状态
  bool _checkboxSelected=true;//维护复选框状态
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Switch(
            value: _switchSelected,//当前状态
            activeColor: Colors.blue,
            activeThumbImage: AssetImage("images/alipay.png"),
            inactiveThumbImage: AssetImage("images/icon_bg_me.png"),
            inactiveTrackColor: Colors.red,
            onChanged:(value){
              //重新构建页面
              setState(() {
                _switchSelected=value;
              });
            },
          ),
          CheckboxListTile(
            title: Text("硬件加速"),
            secondary: Icon(Icons.toys),
            value: _checkboxSelected,
            activeColor: Colors.red, //选中时的颜色
            checkColor: Colors.blue,
            onChanged:(value){
              setState(() {
                _checkboxSelected=value;
              });
            } ,
          )
        ],
      ),
    );
  }
}

